<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.19.2/axios.js"></script>
    <script>

        // 这个函数的返回值是一个promise
        function getData1 () {
            const result = axios({
                method: 'GET',
                url: 'http://ttapi.research.itcast.cn/app/abcddddddd'
            })
            console.log(result)
            return result
        }

        function getData2 () {
            const result = axios({
                method: 'GET',
                url: 'http://www.liulongbin.top:3006/api/getbooks'
            })
            console.log(result)
            return result
        }
        //getData()

        async function test() {
           console.log('请求发出之前')
           // await的作用是取出其后promise对象中的值：PromiseValue
           try {
            let data1 =  await getData1()
            console.log('data1请求回来之后')
            console.log(data1)

            let data2 =  await getData2()
            console.log('data2请求回来之后')
            console.log(data2)
           } catch (err) {
               console.log(err)
           }
        }

        test()


    </script>
</body>
</html>